/*
 *	This file is part of Lounge-Cast.
 *
 *  Author:  	Markus Moormann
 *	E-mail:  	mmoorman@uni-osnabrueck.de
 *	Copyright:	University of Osnabrueck (Zentrum Virtuos)
 * 	Website:	www.uni-osnabrueck.de
 *	Date:		16.02.2011
 *
 *	Lounge-Cast is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *	Lounge-Cast is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Lounge-Cast.  If not, see <http://www.gnu.org/licenses/>.
 */
package multimedia.model.vo
{
	/**
	 * base class for all media classes
	 */
	[Bindable]
	[RemoteClass(alias="backend.vo.MediaVO")]
	public class MediaVO
	{
		
		/**
		 * static value for text media
		 */
		public static const TEXT:String = "text";
		/**
		 * static value for slide media
		 */
		public static const SLIDE:String = "slide";
		/**
		 * static value for video media
		 */
		public static const VIDEO:String = "video";
		/**
		 * static value for image media
		 */
		public static const IMAGE:String = "image";

		/**
		 * internal id of the media
		 */
		public var media_id:String;
		/**
		 * type of the media (one of the static values)
		 */
		public var type:String;
		/**
		 * title of the media
		 */
		public var title:String;
		/**
		 * start date of the media 
		 */
		public var start_date:Number;
		/**
		 * valid date of the media
		 */
		public var valid_date:Number;
		/**
		 * whether the newsticker is shown or not
		 */
		public var newsticker:Boolean;
		/**
		 * duration of the media
		 */
		public var duration:Number;
		/**
		 * further reference to this media
		 */
		public var reference:String;
		/**
		 * timestamp when added
		 */
		public var added:Number;
		/**
		 * the user who added the media
		 */
		public var addedBy:UserVO;
		/**
		 * whether the media is approved or not
		 */
		public var approved:Boolean;
		/**
		 * whether the media is converted or not
		 * just important for slides that need to be
		 * converted to SWF before show
		 */
		public var converted:Boolean = true;
		
		/**
		 * position of the media in a playlist
		 */
		public var position:Number = 0;
		
		/**
		 * the playlist the media belongs to
		 */
		public var playlist_id:Number = 0;
		
		/**
		 * feed this media blongs to
		 */
		public var feed:FeedVO;
		/**
		 * the feed_item_uri if this media belongs to a feed item
		 */
		public var feed_item_uri:String;
		/**
		 * the category 
		 */
		public var category:CategoryVO;
		
		public var hide_title:Boolean;
		
		public var title_color:uint;
		
		/**
		 * method to get an instance of MediaVO
		 * 
		 * @param media_id the id of the media (MD5(title + timestamp))
		 * @param type the type of the media
		 * @param valid_date the valid date of the media
		 * @param newsticker whether the newsticker is shown or not
		 * @param duration the duration of the media
		 * @param reference further reference to this media
		 * 
		 * @return an instance of MediaVO containing the given information 
		 */
		public static function getInstance( media_id:String,
											type:String, 
											title:String,
											valid_date:Number, 
											newsticker:Boolean, 
											duration:Number, 
											reference:String):MediaVO
		{
			var media:MediaVO = new MediaVO;
			media.media_id = media_id;
			media.type = type;
			media.title = title;
			media.valid_date = valid_date;
			media.newsticker = newsticker;
			media.duration = duration;
			media.reference = reference;
			media.converted = true;
			return media;
		}
		
		/**
		 * method to clone the media
		 * 
		 * @return a new instance of MediaVO containing the same information than the instance who called the method
		 */
		public function clone():MediaVO
		{
			var media:MediaVO = getInstance(media_id, 
											type, 
											title, 
											valid_date,
											newsticker, 
											duration, 
											reference);
			media.added = added;
			media.addedBy = addedBy;
			media.approved = approved;
			media.converted = converted;
			media.position = position;
			media.playlist_id = playlist_id;
			media.feed = feed;
			media.hide_title = hide_title;	
			media.title_color = title_color;
			return media;
		}

	}
}